{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}
<style>
	#tab-member table tr td:nth-child(1),#tab-member table tr td:nth-child(3){font-weight: bold;color:#000;}
</style>
<script>
    /*凭证图片缩扩滚动*/
    function zoomImg(o) {
        var zoom = parseInt(o.style.zoom, 10) || 100;
        zoom += event.wheelDelta / 2; //可适合修改
        if (zoom > 0) o.style.zoom = zoom + '%';
    }
    $(document).ready(function() {
        $(".shadow_img").bind("mousewheel",
            function() {
                zoomImg(this);
                return false;
            });
    });
</script>
<div class="page-header">
		<h1>
			{$breadcrumb2}
			<small>
				<i class="ace-icon fa fa-angle-double-right"></i>
				{$crumbs}
			</small>
		</h1>
</div>	
	<ul class="nav nav-tabs">
	
	</ul>

	<form class="form-horizontal" id="validation-form"  method="post" action='{:url("exception/apply")}'>	
	<div class="tab-content">			
		<div class="tab-pane active" id="tab-member">
			<table class="table table-bordered">
				<tr>
				    <td>ID</td>
				    <td style="width: 35%">{$data.info.id}</td>
				    <input type="hidden" name="id" value="{$data.info.id}" />
				    <td style="font-weight: bold;color: #000;">手机号码</td>
				    <td>{$data.info.username}</td>


				</tr>
				<tr>
				    <td>姓名</td>
				    <td>{$data.info.id_name}</td>
				    <td>身份证号</td>
				    <td>{$data.info.id_card}</td>


				</tr>

				<tr>
				    <td>交易所账号</td>
				    <td>{$data.info.trade_id}</td>
				    <td>交易所副账号</td>
				    <td>{$data.info.sub_trade_id}</td>


				</tr>											
				<tr>
					<td>交易所</td>
					<td>
						<select name="exchange_id" id ="exchange_id"  style="width:400px;" >
			                  <option value ="-1">--请选择交易所--</option> 
			                  {volist name="exchange" id="p" empty="$exchange"}
			                  <option value ="{$p.id}" {if condition="$p.id eq $data.info.exchange_id"}selected{/if}>{$p.name}</option>              
			                  {/volist}  
            			</select> 
            		</td>
					<td>交易品种</td>
					<td>
					<select name="variety_id" id ="variety_id"  style="width:400px;" tabindex="4">
	                  <option value ="-1">--请选择交易品种--</option> 
	                  {volist name="variety" id="p" empty="$variety"}
	                   
	                  {if condition="$p.id eq $data.info.exchange_variety_id"}
	                 	<option value ="{$p.id}" selected>{$p.name}</option> 
	                 {/if}            
	                  {/volist}
					</select>
					</td>
				</tr>
				<tr>
				    <td>交易品种ID</td>
				    <td>{$data.info.variety_id}</td>
				    <td>当前轮次</td>
				    <td>第{$data.info.rang-1}轮</td>
				    <input type="hidden" readonly="true" name="rang" id="rang" value="{$data.info.rang}">
				</tr>
				<tr>
				    <td>买入数量</td>
				    <td><input name="buy_num" readonly="true" id="buy_num" type="text" style="width:400px;" value="{$data.info.buy_num}" /></td>

				    <td>买入价格</td>
				    <td><input name="buy_price" readonly="true" id="buy_price" type="text" style="width:400px;" value="{$data.info.buy_price}" /></td>
				    
				</tr>

				<tr>
				    <td>买入时间</td>
				    <td><input name="buy_time" readonly="true" type="text" style="width:400px;" value="{$data['info']['buy_time']}" /></td>
				    <td>卖出数量</td>
				    <td><input name="sell_num" readonly="true" id="sell_num" type="text" style="width:400px;" value="{$data.info.sell_num}"   /></td>
				    
				</tr>
				<tr>
				    <td>卖出价格</td>
				    <td><input name="sell_price" readonly="true" id = "sell_price" type="text" style="width:400px;" value="{$data.info.sell_price}" /></td>
				    <td>卖出时间</td>
				    <td><input name="sell_time" readonly="true" type="text" style="width:400px;" value="{$data['info']['sell_time']}" /></td>
				    
				</tr>
				
				<tr>
				    <td>异常情况描述</td>
				    <td><textarea rows="7" readonly="true"  style="width: 100%" shape="" coords="" href="">{$data['info']['exception_desc']}</textarea>
				    </td>
				    <td>审批意见</td>
				    <td><textarea name="exception_apply_desc" rows="7"  style="width: 100%" shape="" coords="" href="">{$data['info']['exception_apply_desc']}</textarea>
				    </td>
				  
				</tr>
				<tr>
					<td>提货记录凭证</td>
					{volist name="img0" id="p" empty=""}
					<!-- 模态框（Modal） -->
					<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
						<div class="modal-dialog" style="height: 100%;width: 100%;margin: 150px auto;">
							<div class="modal-content shadow_img">
								<div class="modal-header" style="border-bottom: none">
									<button type="button" class="close" style="margin-top: -12px" data-dismiss="modal" aria-hidden="true">
										&times;
									</button>
									<h4 class="modal-title" id="myModalLabel">
									</h4>
								</div>
								<div class="modal-body">
									<img src="{$p.img_path}" style="display: block;margin: 0 auto;">
								</div>
							</div><!-- /.modal-content -->
						</div><!-- /.modal -->
					</div>
					<td style="border-right: none;">

						<div class="over"></div><!--背景层-->
						<div class="logoImg amplifyImg"><!--注意：此处的amlifyImg不可少-->
							<img src="{$p.img_path}"  data-toggle="modal" data-target="#myModal" class="certificate" style="width: 20%;height: 20%;"/>
						</div>
					</td>
					<td style="border-left: none;border-right: none;"></td>
					<td style="border-left: none;"></td>
					{/volist}
				</tr>
				<tr>
					<td>操作</td>
					<td>	
							<label class="radio-inline">
							<input type="radio" checked="checked" value="1" name="checked">审核通过</label>
							<label class="radio-inline">
							<input type="radio" value="2" name="checked">审核不通过</label>

					</td>
				</tr>
		    </table>

			<div class="form-group">
				
				<div style="margin-left:20px;">
					<input name="send" type="submit" value="提交" class="btn btn-primary" />
				</div>
			</div>
		</div>
	</div>
	</form>

{/block}
{block name="javascript"}

<script type="text/javascript">
	$('#exchange_id').change(function(){
		//alert("abc");
		var iframe_array = <?php echo  json_encode($variety);   ?>;
    	var checkValue=jQuery("#exchange_id").val();
    	//alert(checkValue);
    	$("#variety_id").empty();  
    	for (var i = 0; i <iframe_array.length ; i++) 
    	{
    		if(iframe_array[i]['exchange_id']==checkValue)
	    	{
	    		var opt = "<option value='"+iframe_array[i]['id']+"'>"+iframe_array[i]['name']+"</option>";
	    		jQuery("#variety_id").append(opt);
	    	}
	    }

	})



</script>
<script type="text/javascript">
	
$('#buy_num').blur(function(){

	//alert("test");
	var rang = {$data.info.rang};
	var buy_num=$('#buy_num').val();
	if(buy_num=='')
	{
		alert('买入数量不能为空！');
	}
	$('#sell_num').val(buy_num);

	if(rang == 2)
	{
		var buy_price = 3000/buy_num;
		buy_price = buy_price.toFixed(2);
		$('#buy_price').val(buy_price);
		var sell_price = 3300/buy_num;

		sell_price = sell_price.toFixed(2);
		$('#sell_price').val(sell_price);
	}


	if(rang == 3)
	{
		var buy_price = 8000/buy_num;
		buy_price = buy_price.toFixed(2);
		$('#buy_price').val(buy_price);
		var sell_price = 8000*1.1/buy_num;
		sell_price = sell_price.toFixed(2);
		$('#sell_price').val(sell_price);
	}

	if(rang == 4)
	{
		var buy_price = 15000/buy_num;
		buy_price = buy_price.toFixed(2);
		$('#buy_price').val(buy_price);
		var sell_price = 15000*1.1/buy_num;
		sell_price = sell_price.toFixed(2);
		$('#sell_price').val(sell_price);
	}
	if(rang == 5)
	{
		var buy_price = 20000/buy_num;
		buy_price = buy_price.toFixed(2);
		$('#buy_price').val(buy_price);
		var sell_price = 20000*1.12/buy_num;
		sell_price = sell_price.toFixed(2);
		$('#sell_price').val(sell_price);
	}

	if(rang == 6)
	{
		var buy_price = 20000/buy_num;
		buy_price = buy_price.toFixed(2);		
		$('#buy_price').val(buy_price);

		var sell_price = 20000*1.2/buy_num;
		sell_price = sell_price.toFixed(2);
		$('#sell_price').val(sell_price);
	}

})

$('#buy_price').blur(function(){

	//alert("test");
	var rang = {$data.info.rang};
	var buy_price=$('#buy_price').val();
	var sell_price = (buy_price*1.1).toFixed(2);
	if(buy_price=='')
	{
		alert('买入价格不能为空！');
	}
	$('#sell_price').val(sell_price);

	if(rang == 2)
	{
		var buy_num = Math.ceil(3000/buy_price);
		$('#buy_num').val(buy_num);
		$('#sell_num').val(buy_num);		
	}


	if(rang == 3)
	{
		var buy_num = Math.ceil(8000/buy_price);
		$('#buy_num').val(buy_num);
		$('#sell_num').val(buy_num);
	}

	if(rang == 4)
	{
		var buy_num = Math.ceil(15000/buy_price);
		$('#buy_num').val(buy_num);
		$('#sell_num').val(buy_num);
	}
	if(rang == 5)
	{
		var buy_num = Math.ceil(20000/buy_price);
		$('#buy_num').val(buy_num);
		$('#sell_num').val(buy_num);
	}

	if(rang == 6)
	{
		var buy_num = Math.ceil(20000/buy_price);
		$('#buy_num').val(buy_num);
		$('#sell_num').val(buy_num);
	}

	//输入价格

})

</script>
<script>
$(function(){	
	
	{if condition="$Request.param.id"}
			Oscshop.setValue("checked", {$data.info.checked|default=1});		
	{/if}
	
	$('.btn').click(function(){		
		
		if($('#pwd').val()==''){
			alert('密码必填');
			return false;
		}
		if($('#pwd').val().length<6){
			alert('密码长度必须大于等于6位！！');
			return false;
		}
	});		
});
</script>							
{/block}